package com.mybatis.lo.handler;

import com.mybatis.lo.mapping.ParameterMapping;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.List;

/**
 * 封装了`JDBC Statement `操作，负责对`JDBC statement`的操作，如`PreparedStatement`的设置参数、将Statement转换成List集合
 * @author zhangbh
 * 2023-06-19 08:44
 **/
public interface StatementHandler {

    Statement prepare(Connection connection) throws SQLException;

    /**
     * 设置参数
     * @param statement statement
     */
    void parameterize(Statement statement) throws SQLException;

    /**
     * 请求数据
     * @param statement statement
     * @return 数据
     */
    <T> List<T> query(Statement statement) throws SQLException, NoSuchFieldException, InstantiationException, IllegalAccessException;
}
